当前位置:flash课件吧→教育→教育教学栏目

www.luotao2008.cn视频网校,仅需要一个耳机+QQ远程即可完成所有教学任务。

题 目:让网页自适应flash大小变化

网页中插入的flash不同于一般网页,一般网页可以根据内容自动更改大小,而flash插入网页后大小就固定了。但是我们可以通过flash与javascript的结合,实现网页随flash的尺寸变化而变化:

flash内代码:鼠标点击时,更改_mc元件的高度,并将新的高度传递给javascript

import flash.external.*;

onMouseDown=function(){
mheight=_mc._height+=50;
ExternalInterface.call("scriptmain_DoFSCommand",mheight)
}

javascript代码:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh_cn" lang="zh_cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>test</title>
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="AC_RunActiveContent.js" language="javascript"></script>
<script LANGUAGE=Javascript>
<!--
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the the FSCommand messages in a Flash movie
function scriptmain_DoFSCommand(args) {
var scriptmainObj = InternetExplorer scriptmain : document.scriptmain;
alert(args)
scriptmain.style.pixelHeight=args;

}
// Hook for Internet Explorer
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 &&
navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
alert(111)
document.write('<script LANGUAGE=VBscript\> \n');
document.write('on error resume next \n');
document.write('Sub scriptmain_FSCommand(ByVal command, ByVal args)\n');
document.write('call scriptmain_DoFSCommand(command, args)\n');
document.write('end sub\n');
document.write('</script\> \n');
}
//-->
</script>

</head>
<body bgcolor="#ffffff">

<script language="javascript">
if (AC_FL_RunContent == 0) {
alert("此页需要 AC_RunActiveContent.js");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
'width', '550',
'height', '400',
'src', 'test',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'top',
'play', 'true',
'loop', 'true',
'scale', 'noscale',
'wmode', 'opaque',
'devicefont', 'false',
'id', 'test',
'bgcolor', '#ffffff',
'name', 'scriptmain',
'menu', 'true',
'allowFullScreen', 'false',
'allowscriptAccess','sameDomain',
'movie', 'test',
'salign', 't'
); //end AC code
}
</script>

</body>
</html>

 

注意标示颜色的部分。

 

 

 

FLASH课件制作培训班开班了!火热报名中!加我站管理QQ444860709解决任何疑问! 培训QQ专业群67042004。